package com.itlong.cloud.app.resource;

import com.itlong.cloud.POJO.VO.app.AppRoomAuthVO;
import com.itlong.cloud.app.service.IAppRoomService;
import com.itlong.cloud.project.app.IAppRoomServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      APP房间信息暴露接口实现类
 * </desc>
 */
@RestController
public class AppRoomServiceResource implements IAppRoomServiceClient{
    @Autowired
    IAppRoomService iAppRoomService;
    /**
     * <desc>
     *      获取用户在项目中已认证的房屋
     * </desc>
     *
     * @param userId 用户id
     * @param projectId 项目id
     * @param owner 是否只查业主 1是 0否
     * @return
     * @author Jiaqi.X
     * @createDate 2017/10/27
     */
    @Override
    @RequestMapping(path = "/app/room/getAuthRoom")
    public List<AppRoomAuthVO> getUseRoomsByUserIdAndProjectId(@RequestParam("userId")String userId,
                                                        @RequestParam("projectId")String projectId,
                                                        @RequestParam("owner")String owner){
        return iAppRoomService.getUseRoomsByUserIdAndProjectId(userId,projectId,owner);
    }

    /**
     * <desc>
     *      添加访客时在非社区场景下获取业主的地址楼层列表
     * </desc>
     *
     * @param userId 用户id
     * @param projectId 项目id
     * @param owner 是否只查业主 1是 0否
     * @return
     * @author Juguang.S
     * @createDate 2021/03/26
     */
    @Override
    @RequestMapping(path = "/app/room/getOwnerUserFloorInfoByProjectId")
    public List<AppRoomAuthVO> getOwnerUserFloorInfoByProjectId(@RequestParam("userId")String userId,
                                                               @RequestParam("projectId")String projectId,
                                                               @RequestParam("owner")String owner){
        return iAppRoomService.getOwnerUserFloorInfoByProjectId(userId,projectId,owner);
    }

    /**
     * <desc>
     *      设置开门密码
     * </desc>
     *
     * @param projectId 项目id
     * @param userId 用户id
     * @param openPwd 开门密码
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/13
     */
    @Override
    @RequestMapping(path = "/app/room/setOpenPwd")
    public Integer setOpenPwd(@RequestParam("projectId") String projectId,
                              @RequestParam("userId") String userId,
                              @RequestParam("openPwd") String openPwd) throws Exception {
        return iAppRoomService.setOpenPwd(projectId,userId,openPwd);
    }

    /**
     * <desc>
     *      获取当前房屋列表，app2.0版本新增
     * </desc>
     *
     * @param projectId 项目编号
     * @param userId 用户id
     * @return 房屋列表
     * @author wangzhi
     * @createDate 2019/06/27
     */
    @Override
    @RequestMapping(path = "/app/room/getHomeList")
    public Map<String, Object> getHomeList(@RequestParam("projectId") String projectId, @RequestParam("userId") String userId) throws Exception {
        return iAppRoomService.getHomeList(projectId, userId);
    }
}
